package com.css.zfzx.sjcj.modules.yhdisaster.controller;

import com.alibaba.fastjson.JSON;
import com.css.zfzx.sjcj.modules.yhdisaster.params.ExportDisasterEvaluateParams;
import com.css.zfzx.sjcj.modules.yhdisaster.service.YhDisasterService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletResponse;

@Slf4j
@Controller
@RequestMapping("/yh/ctrl/yhDisasters")
public class YhDisasterNonRestController {

    private final YhDisasterService yhDisasterService;

    @Autowired
    public YhDisasterNonRestController(YhDisasterService yhDisasterService) {
        this.yhDisasterService = yhDisasterService;
    }

    @GetMapping("/exportDisasterEvaluation")
    public void exportDisasterEvaluation(@RequestParam String exportParams,
                                                         HttpServletResponse response) {
        try {
            ExportDisasterEvaluateParams params = JSON.parseObject(exportParams, ExportDisasterEvaluateParams.class);
            yhDisasterService.exportDisasterEvaluation(params, response);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}